import type { CrudConfig } from '@/features/share/crudtemplate/crudFactory'

const brandConfig: CrudConfig = {
  // 页面基本信息
  page: {
    title: '品牌管理',
    description: '管理系统中的品牌信息',
    permission: 'acl:brand',
    targetNameField: 'tmName',
  },

  // API接口配置
  api: {
    GET_URL: '/brand/list',
    CREATE_URL: '/brand/save',
    UPDATE_URL: '/brand/update',
    DELETE_URL: '/brand/remove',
    BATCH_DELETE_URL: '/brand/batchRemove',
  },

  // 搜索配置
  search: {
    fields: [
      {
        prop: 'tmName',
        label: '品牌名称',
        type: 'input',
        placeholder: '按品牌名称搜索',
        clearable: true,
      },
    ],
  },

  // 表格列配置
  tableColumns: [
    {
      type: 'selection',
      label: '选择',
      width: 'auto',
      align: 'center',
    },
    {
      type: 'index',
      label: 'ID',
      width: 'auto',
      align: 'center',
    },
    {
      prop: 'tmName',
      label: '品牌名称',
      minWidth: 'auto',
      align: 'center',
      sortable: true,
    },
    {
      prop: 'logoUrl',
      label: '品牌Logo',
      type: 'image',
      minWidth: 120,
      align: 'center',
      imageConfig: {
        width: 80,
        height: 80,
        round: false,
        preview: true,
      },
    },
  ],

  // 表格操作列配置
  tableActionColumn: {
    width: 'auto',
    align: 'center',
    fixed: 'right',
  },

  // 表格操作列按钮配置
  tableActions: [
    {
      text: '编辑',
      label: '编辑',
      type: 'primary',
      size: 'small',
      plain: true,
      permission: 'btn.Brand.update',
      action: 'edit',
    },
    {
      text: '删除',
      label: '删除',
      type: 'danger',
      size: 'small',
      plain: true,
      permission: 'btn.Brand.remove',
      action: 'delete',
    },
  ],

  // 表单配置
  form: {
    fields: [
      {
        prop: 'tmName',
        label: '品牌名称',
        type: 'input',
        placeholder: '请输入品牌名称',
        required: true,
        maxlength: 50,
        showWordLimit: true,
      },
      {
        prop: 'logoUrl',
        label: '品牌Logo',
        type: 'upload',
        required: true,
        uploadConfig: {
          action: '/upload/logo',
          name: 'file',
          accept: 'image/*',
          maxSize: 2,
          tips: ['支持 JPG/PNG 格式', '大小不超过 2MB'],
        },
      },
    ],
    rules: {
      tmName: [
        { required: true, message: '请输入品牌名称', trigger: 'blur' },
        { min: 2, max: 50, message: '品牌名称长度在 2 到 50 个字符', trigger: 'blur' },
      ],
    },
    labelWidth: '100px',
    dialogWidth: '600px',
    addTitle: '新增品牌',
    editTitle: '编辑品牌',
  },

  // 操作按钮配置
  actions: {
    add: {
      text: '新增品牌',
      icon: 'Plus',
      permission: 'btn.Brand.add',
    },
    batchDelete: {
      text: '批量删除',
      icon: 'Delete',
      permission: 'btn.Brand.remove',
    },
  },

  // 分页配置
  pagination: {
    pageSizes: [10, 20, 50, 100],
    defaultPageSize: 10,
  },

  // 消息配置
  messages: {
    loadSuccess: '品牌获取成功',
    addSuccess: '品牌添加成功！',
    editSuccess: '品牌修改成功！',
  },
}

export default brandConfig
